//
//  RootViewController.m
//  Waiguofang
//
//  Created by waiguofang on 14-8-27.
//
//

#import "RootViewController.h"
#import "config.h"

@interface RootViewController ()
@property (nonatomic, strong) UIView * remindView;
- (void)inintComponts;



@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.navigationController.navigationBar.tintColor = [UIColor clearColor];
    self.topNavbarView  = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    [self.topNavbarView  setBackgroundColor:UIColorFromRGB(0x7FCFB3)];
    
   
    
   // [self.view setBackgroundColor:[UIColor colorWithHex:0xF1F1F1 alpha:1]];
  // [self.navigationController.navigationBar addSubview:self.topNavbarView];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if ([self.navigationController viewControllers].count > 1 ) {
        [self setBackNavigation];
    }
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    if (self.topNavbarView.superview) {
 
        [self.topNavbarView removeFromSuperview];
    }
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

#pragma mark --Private
- (void)inintComponts
{
    //UIView *
}

#pragma mark --title Navi
- (void)setTitleNavigation:(NSString *)naviTitle {
    self.navigationItem.title = naviTitle;
}

- (void)setTitleViewNavigation:(NSString *)naviTitle {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(-60, 0, 200, 44)];
    view.backgroundColor = [UIColor clearColor];
    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
    lable.backgroundColor = [UIColor clearColor];
    lable.text = naviTitle;
    lable.textColor = [UIColor whiteColor];
    lable.font = [UIFont boldSystemFontOfSize:20];
    [view addSubview:lable];
    self.navigationItem.titleView = view;
    return;
}

- (void)setLeftBarButtonItem:(UIBarButtonItem *)buttonItem{
    self.navigationItem.leftBarButtonItem = buttonItem;
}

- (void)setRightBarButtonItem:(UIBarButtonItem *)buttonItem{
    self.navigationItem.rightBarButtonItem = buttonItem;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

#pragma mark --backnavigation

- (void)setBackNavigation {

    UIView *barView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    //[barView setBackgroundColor:[UIColor colorWithHex:0x60a410 alpha:1]];
    [barView setBackgroundColor:[UIColor clearColor]];
    self.navigationItem.titleView = barView;
    
    UIImage *imgNormal = [UIImage imageNamed:@"anjuke_50icon06_normal.png"];
    UIImage *imgHighLight = [UIImage imageNamed:@"anjuke_50icon06_normal.png"];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(5, 0, imgNormal.size.width, 44);
    [button setImage:imgNormal forState:UIControlStateNormal];
    [button setImage:imgHighLight forState:UIControlStateHighlighted];
    [button addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.topNavbarView addSubview:button];
    return;
    

}

- (void)backButtonClick {
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark --rightnavigation
- (void)setRightNavigation:(NSString *)rightNaviName {

}

- (void)setLeftNavigation:(NSString *)rightNaviName {
    
}

- (void)rightBarButtonAction:(id)sender
{
    
}

- (void)leftBarButtonAction:(id)sender {
    
}

- (UIView *)setupBackgroundView {
    CGRect frame = [[UIScreen mainScreen] applicationFrame];
    UIView *view = [[UIView alloc] initWithFrame:frame];
    view.backgroundColor = [UIColor whiteColor];
    return view;
}

- (void)showMessage:(NSString *)message
{
    [self showMessage:message duration:1.0f];
}

- (void)showMessage:(NSString *)message duration:(CGFloat)duration
{
    [SVProgressHUD showWithOnlyStatus:message duration:duration];
}

#pragma no result remind
- (void)setNoDataRemindView:(BOOL)isShowView
{
//    if (isShowView) {
//        self.remindView = [[UIView alloc] initWithFrame:self.view.bounds];
//        
//        self.remindView.backgroundColor = [UIColor colorWithHex:0xFFFFFF alpha:1];
//        
//        UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 75, 90)];
//        imgV.center = self.remindView.center;
//        imgV.centerY = imgV.centerY-50;
//        
//        [imgV setImage:[UIImage imageNamed:@"no_results_sign.png"]];
//        
//        UILabel *labRemind = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 130, 25)];
//        labRemind.top = imgV.bottom+2;
//        labRemind.centerX = self.view.centerX;
//        [labRemind setText:@"共搜索到0条相关房源!"];
//        labRemind.font = [UIFont systemFontOfSize:13];
//        [labRemind setTextColor:[UIColor grayColor]];
//        labRemind.textAlignment = NSTextAlignmentCenter;
//        
//        [self.remindView addSubview:imgV];
//        [self.remindView addSubview:labRemind];
//        
//        [self.view addSubview:self.remindView];
//    }
//    else
//    {
//        if ([self.remindView superview]) {
//            [self.remindView removeFromSuperview];
//        }
//    }
}

@end
